<template>
    <rx-layout>
        <template v-slot:center>
            <div class="myCollection">
                <div v-if="collection.length>0">
                    <div @click="myCollection(item)" class="myCollection-common" v-for="item in collection">
                        <span>{{ $i18(item.name) }}</span>
                    </div>
                </div>
            </div>
        </template>
    </rx-layout>
</template>

<script>
import RxLayout from '@/components/RxLayout'
import MainLayoutApi from "../../api/MainLayout/MainLayoutApi";
import TokenUtil from "../../common/TokenUtil";
import Constants from '@/common/constants.js'

export default {
    name: "MyShare",
    components: {
        RxLayout
    },
    data() {
        return {
            collection: [],//我的收藏列表
            appId:'',
        }
    },
    onLoad(option) {
        this.appId = option.appId?option.appId:uni.getStorageSync("mobileAppId")
        this.init()
    },
    methods: {
        i18n(name, text, key) {
            return this.$ti18(name, text, "bpmLang", key);
        },
        init() {
            MainLayoutApi.getShareWithMe(this.appId).then(res => {
                if (res.success) {
                    this.collection = res.data
                }
            })
        },
        myCollection(type) {
            let wPath = ""
            // #ifdef H5
            wPath = window.document.location.origin;
            // #endif
            // #ifdef APP-PLUS
            wPath = Constants.app_origin;
            // #endif
            let token = TokenUtil.getToken();
            let item = wPath + '/screen/mobile/' + type.alias+'?token='+token;
            let url = '/pages/RxIframe/RxIframe?url=' + item +'&title='+this.$i18(type.name);
            uni.navigateTo({
                url: url
            })
        }
    }
}
</script>

<style scoped>
.myCollection-common {
    border-radius: 5px;
    height: 3rem;
    line-height: 3rem;
    padding-left: 1rem;
    background: white;
    margin-bottom: 1rem;
}
</style>
